package com.bbz.core.Singleton;

/**
 * 使用enum实现单例模式
 */
public class SingletonDemo2 {
    public enum MyEnumSingleton{
        myObjectSingle;
        private MyObject myObject;
        private MyEnumSingleton(){
            myObject=new MyObject();
        }
        public MyObject getMyObject(){
            return myObject;
        }
    }
    public static MyObject getMyObject(){
        return MyEnumSingleton.myObjectSingle.getMyObject();
    }
}
